package com.magenta.maxoptra.geocoding.geobase.webservice;

import javax.xml.namespace.QName;
import javax.xml.ws.Service;
import javax.xml.ws.WebEndpoint;
import javax.xml.ws.WebServiceClient;
import java.net.URL;

/**
 * Project: Santa-cruz
 * Author:  Irina Isaeva
 * Created: 08.06.12 14:25
 * <p/>
 * Copyright (c) 1999-2012 Magenta Corporation Ltd. All Rights Reserved.
 * Magenta Technology proprietary and confidential.
 * Use is subject to license terms.
 * <p/>
 * $Id$
 */
@WebServiceClient(name = "GeoBaseWs", targetNamespace = "http://www.telogis.com/geobase/")
public class ExtendedGeoBaseWs extends Service {

    private ObjectPool<GeoBaseWsSoap> pool;

    public ExtendedGeoBaseWs(URL wsdlLocation) {
        super(wsdlLocation, new QName("http://www.telogis.com/geobase/", "GeoBaseWs"));
        initPool();
    }

    private void initPool() {
        pool = new ObjectPool<GeoBaseWsSoap>("GeoBaseWsSoap") {
            @Override
            protected GeoBaseWsSoap create() {
                return getPort(new QName("http://www.telogis.com/geobase/", "GeoBaseWsSoap"), GeoBaseWsSoap.class);
            }
        };
    }

    /**
     * @return returns GeoBaseWsSoap
     */
    @WebEndpoint(name = "GeoBaseWsSoap")
    public GeoBaseWsSoap getGeoBaseWsSoap() {
        return pool.checkOut();
    }

    public void finish(GeoBaseWsSoap proxy) {
        pool.checkIn(proxy);
    }

    public void invalidate(GeoBaseWsSoap proxy) {
        pool.invalidate(proxy);
    }


}
